<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');





class PerfilAdmin extends CI_Controller {

	/**
	 * Index Page for this controller.
	 *
	 * Maps to the following URL
	 * 		http://example.com/index.php/welcome
	 *	- or -  
	 * 		http://example.com/index.php/welcome/index
	 *	- or -
	 * Since this controller is set as the default controller in 
	 * config/routes.php, it's displayed at http://example.com/
	 *
	 * So any other public methods not prefixed with an underscore will
	 * map to /index.php/welcome/<method_name>
	 * @see http://codeigniter.com/user_guide/general/urls.html
	 */
	
	
	
	public function index()
	{	
		
		if($this->session->userdata('logueado')){
			$data = array();
			$data['nombre'] = $this->session->userdata('nombre');
			$data['tipo'] = $this->session->userdata('tipo');
			if ($data['tipo']=='administrador'){
				$this->load->view('headerAdmin', $data);
				$id = $this->session->userdata('id');
				$this->load->model('usuarios_model');
				$data2['usuario']= $this->usuarios_model->buscar2($id);		
				$this->load->view('perfilAdmin', $data2);
				$this->load->view('footerAdmin');
			} 
			else if ($data['tipo']=='admin'){
				$this->load->view('headerAdmin', $data);
				$id = $this->session->userdata('id');
				$this->load->model('usuarios_model');
				$data2['usuario']= $this->usuarios_model->buscar2($id);		
				$this->load->view('perfilAdmin', $data2);
				$this->load->view('footerAdmin');
			} else {
				$this->load->view('header', $data);
				$id = $this->session->userdata('id');
				$this->load->model('usuarios_model');
				$data2['usuario']= $this->usuarios_model->buscar2($id);		
				$this->load->view('inicio', $data2);
				$this->load->view('footer');
			}
		}else{
			redirect('usuarios/iniciar_sesion');
		}
		
		
		//$this->load->view('BanqueroVista');
	}


	public function modificar(){
		$id = $_GET["num"];
		/*$new = array(
					'nombre' => $this->input->post('nombre'),
					'descripcion' => $this->input->post('descripcion'),
					'fecha' => $this->input->post('fecha'),
					'hora' => $this->input->post('hora'),
				);

		print_r($new);exit();*/
		$this->load->library('form_validation');
		$this->load->model('usuarios_model');
		
		$data2['usuario'] = $this->usuarios_model->buscar2($id);
		
		$this->load->view('detalleUsuario',$data2);

	}

	public function guardarcambios(){
		$id = $this->session->userdata('id');
		$data= array(
					'usuario' => $this->input->post('nombre'),
					'apellido' => $this->input->post('apellido'),
					'nombre' => $this->input->post('usuario'),
					'contrasena' => $this->input->post('contrasena'),
					'mail' => $this->input->post('mail'),
					'direccion' => $this->input->post('direccion'),
					'telefono' => $this->input->post('telefono'),
					'fecha_nac' => $this->input->post('nacimiento'),
					'tipo' => $this->input->post('tipo'),
			);
		
		$this->load->model('usuarios_model');
		$us = $this->usuarios_model->edit($id,$data);
		redirect('/perfilAdmin');
        exit();

	}
		
		
	
}

/* End of file welcome.php */
/* Location: ./application/controllers/welcome.php */